//json
//车垱信息
function main(tbl){
	let url="http://www.jidaoyouxin.com/api/v1/car_info";
	let tab1=new JseMap();
	if(isEmpty(tbl.number)||tbl.number.length<5){
		return {code:1101,msg:"请输入正确车牌号"}
	}else{
		let number=tbl.number.substring(1).toUpperCase();
		let province=tbl.number.substring(0,1)
		tab1.put("number",number)
		tab1.put("province",province)
	}
	if(isEmpty(tbl.category)){
		return {code:1101,msg:"车牌类型category不能为空"}
	}else{
		tab1.put("category",tbl.category)
	}
	if(isEmpty(tbl.name)){
		return {code:1101,msg:"车主姓名name不能为空"}
	}else{
		tab1.put("name",tbl.name)
	}
	let u=attr("u")
	let lang="en";
	if(!isEmpty(tbl.lang)){
		lang=tbl.lang;
	}
	let time1=System.currentTimeMillis();
	let res={}
	let reqres="请求成功"
		let resmsg="查询成功"
	let tb=dao.fetch("car_info",Cnd.where("tbl","=",tab1.tourl()))
	if(tb!=null){
		res= baozhuang(tb.result,lang,tbl.name);
	}else{
		let head=Header.create();
		head.set("Content-Type", "application/json");
		head.set("X-Access-Id", "10262");
		head.set("X-Token", "0e41f544-fdca-11e8-b345-00163e0ccd63");
		let text=Http.post3(url,toJson(tab1),head,16000).getContent();
		res=foJson(text);
		if(res.code!=0){
			resmsg="查无数据"
			res.code=404;
			res.msg=resmsg;
		}else{
			resmsg="查询成功"
			res.code=200;
			res=baozhuang(res,lang,tbl.name);
			let tab=new Record();
			tab.put(".table","car_info")
			tab.put("type","车挡信息")
			tab.put("tbl",tab1.tourl())
			tab.put("result",text)
			dao.insert(tab)
		}
	}
	let time2=System.currentTimeMillis();
	let time3=(time2-time1)+1;
	let tab=new Record();
	tab.put(".table","app_log")
	tab.put("username",u.username)
	tab.put("ms",time3)
	tab.put("uid",u.id)
	tab.put("type",u.type)
	tab.put("ip",ip())
	tab.put("reqres",reqres)
	tab.put("resmsg",resmsg)
	tab.put("param",tbl.tourl())
	$save(tab)
	if(resmsg=="查询成功"){
		$update({".table":"app_buy","cxnum":u.cxnum+1,"id":u.bid})
	}
	
	return res;
}
var dicts={"xh":"序号",
		"hpzl":"号牌种类",
		"hphm":"号牌号码",
		"clpp1":"中文品牌",
		"clxh":"车辆型号",
		"clsbdh":"车辆识别代号",
		"fdjh":"发动机号",
		"cllx":"车辆类型",
		"csys":"车身颜色",
		"syxz":"使用性质",
		"syr":"机动车所有人",
		"ccdjrq":"初次登记",
		"yxqz":"有效期止",
		"qzbfqz":"报废期止",
		"zt":"机动车状态",
		"fdjxh":"发动机型号",
		"rlzl":"燃料种类",
		"pl":"排量",
		"gl":"功率","zs":"轴数","zj":"轴距",
		"qlj":"前轮距","hlj":"后轮距","zzl":"总质量","zbzl":"整备质量",
		"hdzzl":"核定载质量","hdzk":"核定载客","ccrq":"出厂日期"}
function baozhuang(res,lang,name){
	if(isEmpty(res.code)){
		res.code=200;
	}
	delete res.query_id
	delete res.result.dataid
	delete res.result.xh
	if(res.result.syr==name){
		res.result["syr"]="一致";
	}else{
		res.result["syr"]="不一致";
	}
	if(lang=="cn"){
		let resmp1=new JseMap();
	for(var item in res.result){
		if(dicts[item]!=null){
			resmp1.put(dicts[item],res.result[item])
		}else{
			resmp1.put(item,res.result[item])
		}
	}
		res.result=resmp1;
	}
	return res;
}